﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lab2.vorkos_dev
{
    class Program
    {
        static void Main(string[] args)
        {
            string username = "";
            int firstnumber = 0;
            int secondnumber = 0;
            double result = 0;
            short correct_flag = 0;

            Console.Write("Enter your name - ");
            username = Console.ReadLine();

            while (correct_flag==0) 
            {
                try
                {
                    Console.Write("Enter first number - ");
                    firstnumber = int.Parse(Console.ReadLine());
                    result = (double)firstnumber / 1;
                    Console.Write("Enter second number - ");
                    secondnumber = int.Parse(Console.ReadLine());
                    result = (double)firstnumber / secondnumber;
                    correct_flag = 1;
                }
             catch
                  {
                    Console.WriteLine("Error! Try again. \n");
                  }
            }

            compare(firstnumber,secondnumber);
            Console.WriteLine("{0} {1}", firstnumber, secondnumber);
            numswap(firstnumber, secondnumber);

            Console.WriteLine("Hello, {0}", String.Concat(username, "!\n", result, " - result. \nPress 'enter' to exit... "));
            Console.ReadLine();
        }

        static void compare(int fnum, int snum)
        {
            if (fnum > snum)
            {
                Console.WriteLine("First number is bigger.\n ");
            }
            else if (fnum < snum)
            {
                Console.WriteLine("Second number is bigger.\n "); 
            }
            else if (fnum == snum)
            {
                Console.WriteLine("Numbers are equal.\n ");
            }
            fnum = 100;
            snum = 200;
            Console.WriteLine("{0} {1}", fnum, snum);
        }

        static void numswap(int fnum, int snum)
        {
            //int tempnum = 0;
            Console.WriteLine("Before xor swap - {0} {1}", fnum, snum);
            //tempnum = fnum;
            //fnum = snum;
            //snum = tempnum;
            fnum = fnum ^ snum;
            snum = snum ^ fnum;
            fnum = fnum ^ snum;
            Console.WriteLine("After xor swap - {0} {1}", fnum, snum);
        }
    }
}
